package com.ff.discounts.api

import com.ff.discounts.boxindexdata.BoxList
import com.ff.discounts.component.address.AddressData
import com.ff.discounts.component.address.NewAreaData
import com.ff.discounts.component.login.LoginRequest
import com.ff.discounts.component.login.TokenData
import com.ff.discounts.entity.response.DetailResponse
import com.ff.discounts.entity.response.ListResponse
import com.ff.discounts.entity.response.OriginalResponse
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path

/**
 * 网络API
 */
interface DefaultNetworkService {

    /**
     * 内容列表
     *
     * @return
     */
    @POST("/api/business/manghe/manghe/mh_lists")
    suspend fun getAllList(
    ): ListResponse<BoxList>


    /**
     * 获取验证码
     */
    @POST("/addons/shopro/sms/send")
    suspend fun getCode(
        @Body data: LoginRequest
    ): OriginalResponse<Any>

    /**
     * 用户密码登录
     */
    @POST("/addons/shopro/user/accountLogin")
    suspend fun passwordLogin(
        @Body data: LoginRequest
    ): DetailResponse<TokenData>
    /**
     * 用户验证码登录
     */
    @POST("/addons/shopro/user/smsLogin")
    suspend fun codeLogin(
        @Body data: LoginRequest
    ): OriginalResponse<Any>

    /**
     *  获取用户地址
     */
    @GET("/addons/shopro/address")
   suspend fun getAddressList():ListResponse<AddressData>

   /**
   * 删除收货地址
   */

   @POST("/addons/shopro/address/del")
   suspend fun deleteAddress(
       @Path("id") id :String
   ): DetailResponse<AddressData>

    /**
    * 添加收货地址
    */
    @POST("/addons/shopro/address/edit")
    suspend fun addAddress(
        @Body data: AddressData
    ): DetailResponse<AddressData>

    /**
    * 获取省市区
    */
    @GET("/addons/shopro/address/area")
    suspend fun getArea():DetailResponse<NewAreaData>

    /// 获取省市区
//    Future<dynamic> getDefaultAddressThree() async {
//        Response res = await _dio.get('/addons/shopro/address/area',
//            options: apiConstant.optionsNoToken);
//        return res.data;
//    }




    // 获取默认收货地址
//    Future<dynamic> getDefaultAddress() async {
//        Response res = await _dio.get('/addons/shopro/address/defaults',
//            options: apiConstant.optionsToken);
//        return res.data;
//    }

    companion object {
        fun create(): DefaultNetworkService {
            return NetworkModule.provideRetrofit(NetworkModule.provideOkHttpClient())
                .create(DefaultNetworkService::class.java)
        }
    }




}